function  writeFeaturesToArff( vehicle_list , featuresToWrite, class, filename)
%writeFeaturesToArff saves an arff file of the vehicle features
%   featuresToWrite = 'hog' or 'wav' for raw, 'selected' for selected
%   class='angle' or 'type' (only 'type' implimented)
    veh=vehicle_list(1);
    if strcmp(featuresToWrite,'hog')
        num_wav_feat=0;
        num_hog_feat=size(veh.hog_featuers,2);
    elseif strcmp(featuresToWrite,'wav')
        num_wav_feat=size(veh.wave_features,1);
        num_hog_feat=0;
    else
        num_wav_feat=size(veh.selected_wave_features,1);
        num_hog_feat=size(veh.selected_hog_features,2);
        
    end
    disp('Step 1')
    num_hog_feat = 17100;
    names=cell(num_wav_feat+num_hog_feat+2,1);
    types=cell(num_wav_feat+num_hog_feat+2,1);
    disp('Step 2')
    for i=1:num_wav_feat
        names(i)={strcat('Wavelet',num2str(i))};
        types(i)={'numeric'};
    end
    disp('Step 3')
    for i=1:num_hog_feat
        names(num_wav_feat+i)={strcat('HOG',num2str(i))};
        types(num_wav_feat+i)={'numeric'};
        
    end 
    disp('Step 4')
    types(num_wav_feat+num_hog_feat+1)={'string'};
    disp('Step 5')
    if strcmp(class,'type')
        names(num_wav_feat+num_hog_feat+1)={'angle'};
        names(num_wav_feat+num_hog_feat+2)={'type'};
        types(num_wav_feat+num_hog_feat+1)={'{f, s, b}'};
        types(num_wav_feat+num_hog_feat+2)={'{truck, car, sport, SUV}'};
    else
<<<<<<< .mine
        disp('Step 6')
        names(num_wav_feat+num_hog_feat+2)={'type'};
        names(num_wav_feat+num_hog_feat+1)={'angle'};
=======
        names(num_wav_feat+num_hog_feat+1)={'type'};
        names(num_wav_feat+num_hog_feat+2)={'angle'};
>>>>>>> .r11
        types(num_wav_feat+num_hog_feat+1)={'{truck, car, sport, SUV}'};
        types(num_wav_feat+num_hog_feat+2)={'{f, s, b}'};
    end
        
    
   disp('Step 7')
    data=cell(size(vehicle_list,2),num_wav_feat+num_hog_feat+2);    
    disp('Step 8')    
    disp(num_wav_feat)
    disp(size(vehicle_list,2))
    disp(num_hog_feat);
  
    for i = 1:size(vehicle_list,2)
        veh=vehicle_list(i);
        if strcmp(featuresToWrite,'selected')
            data(i,1:num_wav_feat)=num2cell([veh.selected_wave_features]);
            data(i,num_wav_feat+1:num_wav_feat+num_hog_feat)=num2cell(veh.selected_hog_features');
        else
            %if num_wav_feat>0
            %    data(i,1:num_wav_feat)=num2cell([veh.wave_features]);
            %end
        
            if num_hog_feat>0
                data(i,num_wav_feat+1:num_wav_feat+num_hog_feat)=num2cell(veh.hog_featuers(1:17100)');
            end
        end
        %disp('Step 10')
        if strcmp(class,'type')
            angletype={veh.camera_angle(1); veh.vehicle_type};
        else
            angletype={veh.vehicle_type; veh.camera_angle(1)};
        end
        data(i,num_wav_feat+num_hog_feat+1:end)=angletype;
    
    end
    disp('Step ENDDDDDDDDDDDD')
    %arffwrite(filename, featuresToWrite, names', types', data)
    %weka_obj=matlab2weka('vehicles', names, data);
    %save_arff('temp.arff', weka_obj);
end

